﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Collections;

namespace employee.Controls
{
    public partial class emEducationDetail : common.controls.baseUserControl
    {
        public emEducationDetail()
        {
            InitializeComponent();
        }

        public void SetDataSource(BindingSource dataSrc)
        {
            common.BindingLibs.BindObject(this.schoolNameEd, dataSrc,DataAccess.DataCache.myBaseDS.emEducation.schoolNameColumn.ColumnName);
            common.BindingLibs.BindObject(this.countryCb, dataSrc, DataAccess.DataCache.myBaseDS.emEducation.schoolCountryColumn.ColumnName);
            common.BindingLibs.BindObject(this.degreeCb, dataSrc, DataAccess.DataCache.myBaseDS.emEducation.degreeColumn.ColumnName);
            common.BindingLibs.BindObject(this.studyFieldEd, dataSrc, DataAccess.DataCache.myBaseDS.emEducation.gradYearColumn.ColumnName, "myItemString");
            common.BindingLibs.BindObject(this.noteEd, dataSrc, DataAccess.DataCache.myBaseDS.emEducation.notesColumn.ColumnName);

            schoolNameEd.MaxLength = DataAccess.DataCache.myBaseDS.emEducation.schoolNameColumn.MaxLength;
            studyFieldEd.maxLen = DataAccess.DataCache.myBaseDS.emEducation.fieldOfStudyColumn.MaxLength;
            studyFieldEd.minSelectedItems = 1;
            noteEd.MaxLength = DataAccess.DataCache.myBaseDS.emEducation.notesColumn.MaxLength;

        }
        public virtual void Init() 
        {
            countryCb.LoadData();
            degreeCb.LoadData();
            gradYearEd.LoadData();
            studyFieldEd.LoadData();
        }

        public virtual bool CheckData()
        {
            bool retVal = true;
            ClearNotifyError();
            //if (schoolNameEd.Text.Trim() == "") 
            //{
            //    NotifyError(schoolNameLbl);
            //    retVal = false;
            //}
            //if (countryCb.myValue == "") 
            //{
            //    NotifyError(countryLbl);
            //    retVal = false;
            //}
            //if (degreeCb.myValue == "")
            //{
            //    NotifyError(degreeLbl);
            //    retVal = false;
            //}
            //if (gradYearEd.myYear == 0)
            //{
            //    NotifyError(gradYearLbl);
            //    retVal = false;
            //}
            //if (studyFieldEd.minSelectedItems >=0  && studyFieldEd.myCheckedValues.Count < studyFieldEd.minSelectedItems) 
            //{
            //    NotifyError(studyFieldLbl);
            //    retVal = false;
            //}
            return retVal;
        }
        public virtual void LockEdit(bool state)
        {
            state = !state;
            schoolNameEd.Enabled = state;
            degreeCb.Enabled = state;
            countryCb.Enabled = state;
            gradYearEd.Enabled = state;
            studyFieldEd.Enabled = state;
            noteEd.Enabled = state;
        }
        public virtual void SetFocus()
        {
            this.Focus();
            schoolNameEd.Focus();
        }
    }
}
